﻿
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- saved from url=(0014)about:internet -->
<html xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:mssdk="winsdk" xmlns:script="urn:script" xmlns:build="urn:build" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="Description" content="AML Debugging Examples"/>
<meta name="MSHAttr" content="PreferredSiteName:MSDN"/>
<meta name="MSHAttr" content="PreferredLib:/library/windows/hardware"/>
<title>AML Debugging Examples</title>

<meta name="MS-HAID" content="t11_rpc_acpi_6e1c6b23-391c-426f-a024-3235c5548783.xml"/>


<link rel="STYLESHEET" type="text/css" HREF="../common/backsdk4.css"/>





<style>
html,div { margin: 0; padding: 0;}

body {
	padding: 0px;
	margin: 0px;
	overflow: auto;
	height: 100%;
}

#winchm_template_button{
	float: right;
	width: 93px;
	top: 7px;
	position: relative;
	text-align: right;
	right: 5px;
	height: auto;
}

#winchm_template_top{
	padding: 0px;
	margin: 0px;
	border-bottom: 1px solid #9B9B9B;
	background-color: #B1CEFE;
}

#winchm_template_navigation{
	margin: 0px;
	padding-top: 7px;
	padding-left: 7px;
	padding-bottom: 3px;
	padding-right: 0px;
	font-size: 8.5pt;
	font-family: Arial, Helvetica, sans-serif;
	font-weight: normal;
	color: #585858;
}

#winchm_template_title{
	margin: 0px;
	padding-top: 4px;
	padding-left: 7px;
	padding-bottom: 7px;
	padding-right: 0px;
	font-size: 18px; 
	font-family: Verdana, Geneva, sans-serif;
	color: #363636;
}

#winchm_template_content{
	margin-top: 20px;
	margin-left: 15px;
	margin-bottom: 20px;
	margin-right: 15px;
	width: auto  !important;
	width: 100%;
}

#winchm_template_footer{
	border-width: 1px;
	border-color: #B1CEFE;
	border-top-style: solid;
	margin-top: 15px;
	margin-left: 15px;
	margin-bottom: 20px;
	margin-right: 15px;
	padding-top: 7px;
	padding-left: 0px;
	padding-bottom: 0px;
	padding-right: 0px;
	font-family: arial, helvetica, sans-serif;
	font-size: 8.5pt;
	color: #696969;
	width: auto;
	text-align: left;
}


#winchm_template_container{
	margin: 0px;
	padding: 0px;
	position: static;
	padding-bottom: 3px;
	overflow: auto;
	background-color: #FFFFFF;
}


@media print
{
#winchm_template_container{
	position: static;	
	margin: 0px;
	padding: 5px;
	
	width: auto;
	height: auto;
	overflow: auto;
}
#winchm_template_button{
visibility:hidden;
}
}

#winchm_template_navigation A:link	{text-decoration: none; color:#004080}
#winchm_template_navigation A:visited  {text-decoration: none; color: #004080}
#winchm_template_navigation A:active {text-decoration: none; color: #004080 }
#winchm_template_navigation A:hover {text-decoration: none;color: #0080FF}

A:link	{text-decoration: underline; color:#0033CC}
A:visited  {text-decoration: underline; color: #0033CC}
A:active {text-decoration: underline; color: #0033CC }
A:hover {text-decoration: underline;color: #FF0000;}
</style>
<script type="text/javascript">
function isMobile(){
Agent = window.navigator.userAgent;
if (Agent.indexOf("iPhone")>=1 || Agent.indexOf("iPad")>=1 || Agent.indexOf("iPod")>=1 || Agent.indexOf("Android")>=1){
return true;
}else{
return false;	
}

}
function d_onresize(){
if (window.navigator.userAgent.indexOf("MSIE")>=1){
document.getElementById('winchm_template_container').style.pixelWidth = document.body.offsetWidth - 3;
document.getElementById('winchm_template_container').style.pixelHeight = document.body.offsetHeight - document.getElementById('winchm_template_top').offsetHeight - 4;
}
document.getElementById('winchm_template_container').style.top = document.getElementById('winchm_template_top').offsetHeight + 'px';
}

function d_onbeforeprint(){
document.getElementById('winchm_template_container').style.width = 'auto';
document.getElementById('winchm_template_container').style.height = 'auto';
}

function d_onafterprint(){
d_onresize();
}

if(!isMobile()){

window.onload = d_onresize;
window.onresize = d_onresize;
window.onbeforeprint = d_onbeforeprint;
window.onafterprint = d_onafterprint;

document.write("<style>\n");
document.write("body {overflow: hidden;}\n");
document.write("#winchm_template_container {position: absolute;overflow: auto;top : 0px;right: 0px;bottom: 0px;left: 0px;}\n");
document.write("</style>\n");
}

</script>
</head>
<body><script language="JavaScript" type="text/JavaScript">
function syn(){
if(parent.nav.tree){
 if(parent.nav.tree.loaded){
  parent.nav.tree.selectNode(1455);
 }else{
  setTimeout("syn()",500);
}
  }else{
  setTimeout("syn()",500);
  }}
if(parent!=self){
  setTimeout("syn()",100);
}else{
  parent.location.href = "../../index.htm?page=debugger/aml_debugging_examples.htm";
}
originalOnload = window.onload;
if(originalOnload==null){
window.onload = function(){parent.contentLoaded = true;};
}else{
window.onload = function(){originalOnload();parent.contentLoaded = true;};
}
</script> 


<div id="winchm_template_top">
	<div id="winchm_template_button"><A href="using_amli_debugger_commands.htm" title="Previous topic"><img id="winchm_template_prev" alt="Previous topic" src="../template2/btn_prev_n.gif" border="0"></a><A href="other_acpi_debugging_extensions.htm" title="Next topic"><img id="winchm_template_next" alt="Next topic" src="../template2/btn_next_n.gif" border="0"></a></div>
	<div id="winchm_template_navigation">Help &gt; 
<A href="introduction6.htm">Debugging Tools for Windows (WinDbg, KD, CDB, NTSD)</A> &gt; <A href="debugging_techniques.htm">Debugging Techniques</A> &gt; <A href="specialized_debugging_techniques.htm">Specialized Debugging Techniques</A> &gt; <A href="acpi_debugging.htm">ACPI Debugging</A> &gt; <A href="the_amli_debugger.htm">The AMLI Debugger</A> &gt; </div>
	<div id="winchm_template_title">AML Debugging Examples</div>
</div>
<div id="winchm_template_container">
	<div id="winchm_template_content"><div id="mainSection"><p>Here are examples that illustrate how to get started with AML debugging.</p>
<h3><a id="investigating_a_frozen_computer"></a><a id="INVESTIGATING_A_FROZEN_COMPUTER"></a>Investigating a Frozen Computer</h3>
<p>If the target computer has frozen and you suspect it may be an ACPI problem, begin by using the <a href="#Bookmark2689"><b>!amli lc</b></a> extension to display all the active contexts:</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli lc
*Ctxt=ffffffff8128d000, ThID=ffffffff81277880, Flgs=----R----, pbOp=ffffffff8124206c, Obj=\_SB.PCI0.ISA0.FDC0._CRS</code></pre>
<p>If no contexts are displayed, the error is probably not ACPI-related.</p>
<p>If there are contexts shown, look for the one marked with an asterisk. This is the <i>current context</i> (the one that is being executed by the interpreter at the present moment).</p>
<p>In this example, the target computer is running Windows XP or Windows Server 2003 on a 32-bit processor. Therefore all addresses are cast to 64 bits, producing a gratuitous FFFFFFFF in the high 32 bits. The abbreviation <b>pbOp</b> indicates the instruction pointer ("pointer to binary op codes"). The <b>Obj</b> field gives the full path and name of the method as it appears in the ACPI tables. For a description of the flags, see <a href="#Bookmark2689"><b>!amli lc</b></a>.</p>
<p></p>
<p>You can use the <a href="#Bookmark2693"><b>!amli u</b></a> command to disassemble the _CRS method as follows:</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli u \_SB.PCI0.ISA0.FDC0._CRS

ffffffff80e4a535 : CreateDWordFieldCRES, 0x76, RAMT)
ffffffff80e4a540 : CreateDWordField(CRES, 0x82, PCIT)
ffffffff80e4a54b : Add(MLEN(), 0x100000, RAMT)
ffffffff80e4a559 : Subtract(0xffe00000, RAMT, PCIT)
ffffffff80e4a567 : Return(CRES)</code></pre>
<h3><a id="breaking_into_the_amli_debugger"></a><a id="BREAKING_INTO_THE_AMLI_DEBUGGER"></a>Breaking Into the AMLI Debugger</h3>
<p>The <a href="#Bookmark2682"><b>!amli debugger</b></a> command causes the AML interpreter to break into the AMLI Debugger the next time any AML code is executed.</p>
<p>After the AMLI Debugger prompt appears, you can use any of the AMLI Debugger commands. You can also use <b>!amli</b> extension commands without prefixing them with "!amli":</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli debugger
kd&gt; g

AMLI(? for help)-&gt; find _crs
\_SB.LNKA._CRS
\_SB.LNKB._CRS
\_SB.LNKC._CRS
\_SB.LNKD._CRS
\_SB.PCI0._CRS
\_SB.PCI0.LPC.NCP._CRS
\_SB.PCI0.LPC.PIC._CRS
\_SB.PCI0.LPC.TIME._CRS
\_SB.PCI0.LPC.IDMA._CRS
\_SB.PCI0.LPC.RTC._CRS
\_SB.PCI0.LPC.SPKR._CRS
\_SB.PCI0.LPC.FHUB._CRS
\_SB.PCI0.SBD1._CRS
\_SB.PCI0.SBD2._CRS
\_SB.MBRD._CRS

AMLI(? for help)-&gt; u \_SB.PCI0._CRS

ffffffff80e4a535 : CreateDWordFieldCRES, 0x76, RAMT)
ffffffff80e4a540 : CreateDWordField(CRES, 0x82, PCIT)
ffffffff80e4a54b : Add(MLEN(), 0x100000, RAMT)
ffffffff80e4a559 : Subtract(0xffe00000, RAMT, PCIT)
ffffffff80e4a567 : Return(CRES)</code></pre>
<h3><a id="using_breakpoints"></a><a id="USING_BREAKPOINTS"></a>Using Breakpoints</h3>
<p>In the following example, you will break into the AMLI Debugger before the method _BST is executed.</p>
<p>Even if you have located a _BST object, you should verify that it is indeed a method. You can use the <a href="#Bookmark2685"><b>!amli dns</b></a> extension to do this.</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli dns /s \_sb.pci0.isa.bat1._bst

ACPI Name Space: \_SB.PCI0.ISA.BAT1._BST (c29c2044)
Method(_BST:Flags=0x0,CodeBuff=c29c20a5,Len=103)</code></pre>
<p>Now you can use the <a href="#Bookmark2680"><b>!amli bp</b></a> command to place the breakpoint:</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli bp \_sb.pci0.isa.bat1._bst</code></pre>
<p>You may also want to place breakpoints within the method. You could use the <a href="#Bookmark2693"><b>!amli u</b></a> command to disassemble _BST and then place a breakpoint on one of its steps:</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli u _sb.pci0.isa.bat1._bst

ffffffffc29c20a5: Acquire(\_SB_.PCI0.ISA_.EC0_.MUT1, 0xffff)
ffffffffc29c20c0: Store("CMBatt - _BST.BAT1", Debug)
ffffffffc29c20d7: \_SB_.PCI0.ISA_.EC0_.CPOL()
ffffffffc29c20ee: Release(\_SB_.PCI0.ISA_.EC0_.MUT1)
ffffffffc29c2107: Return(PBST)

kd&gt; !amli bp c29c20ee</code></pre>
<h3><a id="responding_to_a_triggered_breakpoint"></a><a id="RESPONDING_TO_A_TRIGGERED_BREAKPOINT"></a>Responding to a Triggered Breakpoint</h3>
<p>In the following example, the method _WAK is running and then encounters a breakpoint:</p>
<pre class="syntax" xml:space="preserve"><code>Running \_WAK method
Hit Breakpoint 0.</code></pre>
<p>Use the <a href="#Bookmark2690"><b>!amli ln</b></a> extension to see the nearest method to the current program counter. The following  example is taken from a Windows 2000 system, so the addresses are shown in 32-bit form:</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli ln
c29accf5: \_WAK</code></pre>
<p>The <a href="#Bookmark2689"><b>!amli lc</b></a> extension displays all the active contexts:</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli lc
 Ctxt=c18b6000, ThID=00000000, Flgs=A-QC-W----, pbOp=c29bf8fe, Obj=\_SB.PCI0.ISA.EC0._Q09
*Ctxt=c18b4000, ThID=c15a6618, Flgs=----R-----, pbOp=c29accf5, Obj=\_WAK</code></pre>
<p>This shows that the active contexts are associated with the methods _Q09 and _WAK. The current context is _WAK. </p>
<p>Now you can use the <a href="#Bookmark2691"><b>!amli r</b></a> command to display more details about the current context. From this you can see useful thread and stack information, as well as arguments passed to _WAK and the local data objects. </p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli r
Context=c18b4000*, Queue=00000000, ResList=00000000
ThreadID=c15a6618, Flags=00000010
StackTop=c18b5eec, UsedStackSize=276 bytes, FreeStackSize=7636 bytes
LocalHeap=c18b40c0, CurrentHeap=c18b40c0, UsedHeapSize=88 bytes
Object=\_WAK, Scope=\_WAK, ObjectOwner=c18b4108, SyncLevel=0
AsyncCallBack=ff06b5d0, CallBackData=0, CallBackContext=c99efddc

MethodObject=\_WAK
c18b40e4: Arg0=Integer(:Value=0x00000001[1])
c18b5f3c: Local0=Unknown()
c18b5f54: Local1=Unknown()
c18b5f6c: Local2=Unknown()
c18b5f84: Local3=Unknown()
c18b5f9c: Local4=Unknown()
c18b5fb4: Local5=Unknown()
c18b5fcc: Local6=Unknown()
c18b5fe4: Local7=Unknown()
c18b4040: RetObj=Unknown()</code></pre>
<h3><a id="tracing__stepping__and_running_aml_code"></a><a id="TRACING__STEPPING__AND_RUNNING_AML_CODE"></a>Tracing, Stepping, and Running AML Code</h3>
<p>If you want to trace through the code, you can turn on full tracing information by using the <a href="#Bookmark2692"><b>!amli set</b></a> extension as follows:</p>
<pre class="syntax" xml:space="preserve"><code>kd&gt; !amli set spewon verboseon traceon</code></pre>
<p>Now you can step through the AML code, watching the code execute line by line. The <b>p</b> command steps over any function calls. The <b>t</b> command will step into function calls.</p>
<pre class="syntax" xml:space="preserve"><code>AMLI(? for help)-&gt; p

c29bfcb7: Store(\_SB_.PCI0.ISA_.ACAD.CHAC(SEL0=0x10e1)
c29c17b1: {
c29c17b1: | Store(LGreater(And(Arg0=0x10e1,0xf0,)=0xe0,0x80)=0xffffffff,Local0)=0xffffffff

AMLI(? for help)-&gt; p

c29c17bb: | If(LNot(LEqual(Local0=0xffffffff,ACP_=0xffffffff)=0xffffffff)=0x0)
c29c17ce: | {
c29c17ce: | | Return(Zero)
c29c17d0: | }
c29c17d0: },Local1)=0x0

AMLI(? for help)-&gt; t

c29bfcd4: Store(\_SB_.PCI0.ISA_.BAT1.CHBP(SEL0=0x10e1)
c29c293d: {
c29c293d: | Store("CMBatt - CHBP.BAT1",Debug)String(:Str="CMBatt - CHBP.BAT1")="CMBatt - CHBP.BAT1"</code></pre>
<p>You may also run methods from within the AMLI Debugger if you choose. For example, you might evaluate the status of the LNKA device by running its control method _STA:</p>
<pre class="syntax" xml:space="preserve"><code>AMLI(? for help)-&gt; run \_sb.lnka._sta
PCI OpRegion Access on region c29b2268 device c29b2120

\_SB.LNKA._STA completed successfully with object data:
Integer(:Value=0x0000000b[11])</code></pre></div></div>	
	<div id="winchm_template_footer">Copyright &copy; 2019. All rights 
reserved. (To change the copyright info, just edit it in template.)</div>
</div>

</body>
</html>
